package org.jivesoftware.smackx.packet;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.jivesoftware.smack.packet.IQ;

public class DiscoverItems extends IQ
{
  private final List<Item> items = new CopyOnWriteArrayList();
  private String node;

  public void addItem(Item paramItem)
  {
    synchronized (this.items)
    {
      this.items.add(paramItem);
      return;
    }
  }

  // ERROR //
  public String getChildElementXML()
  {
    // Byte code:
    //   0: new 33	java/lang/StringBuilder
    //   3: dup
    //   4: invokespecial 34	java/lang/StringBuilder:<init>	()V
    //   7: astore_1
    //   8: aload_1
    //   9: ldc 36
    //   11: invokevirtual 40	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   14: pop
    //   15: aload_0
    //   16: invokevirtual 43	org/jivesoftware/smackx/packet/DiscoverItems:getNode	()Ljava/lang/String;
    //   19: ifnull +26 -> 45
    //   22: aload_1
    //   23: ldc 45
    //   25: invokevirtual 40	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   28: pop
    //   29: aload_1
    //   30: aload_0
    //   31: invokevirtual 43	org/jivesoftware/smackx/packet/DiscoverItems:getNode	()Ljava/lang/String;
    //   34: invokevirtual 40	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   37: pop
    //   38: aload_1
    //   39: ldc 47
    //   41: invokevirtual 40	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   44: pop
    //   45: aload_1
    //   46: ldc 49
    //   48: invokevirtual 40	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   51: pop
    //   52: aload_0
    //   53: getfield 21	org/jivesoftware/smackx/packet/DiscoverItems:items	Ljava/util/List;
    //   56: astore 4
    //   58: aload 4
    //   60: monitorenter
    //   61: aload_0
    //   62: getfield 21	org/jivesoftware/smackx/packet/DiscoverItems:items	Ljava/util/List;
    //   65: invokeinterface 53 1 0
    //   70: astore 6
    //   72: aload 6
    //   74: invokeinterface 59 1 0
    //   79: ifne +18 -> 97
    //   82: aload 4
    //   84: monitorexit
    //   85: aload_1
    //   86: ldc 61
    //   88: invokevirtual 40	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   91: pop
    //   92: aload_1
    //   93: invokevirtual 64	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   96: areturn
    //   97: aload_1
    //   98: aload 6
    //   100: invokeinterface 68 1 0
    //   105: checkcast 6	org/jivesoftware/smackx/packet/DiscoverItems$Item
    //   108: invokevirtual 71	org/jivesoftware/smackx/packet/DiscoverItems$Item:toXML	()Ljava/lang/String;
    //   111: invokevirtual 40	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   114: pop
    //   115: goto -43 -> 72
    //   118: astore 5
    //   120: aload 4
    //   122: monitorexit
    //   123: aload 5
    //   125: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   61	85	118	finally
    //   97	123	118	finally
  }

  public Iterator<Item> getItems()
  {
    synchronized (this.items)
    {
      Iterator localIterator = Collections.unmodifiableList(this.items).iterator();
      return localIterator;
    }
  }

  public String getNode()
  {
    return this.node;
  }

  public void setNode(String paramString)
  {
    this.node = paramString;
  }

  public static class Item
  {
    public static final String REMOVE_ACTION = "remove";
    public static final String UPDATE_ACTION = "update";
    private String action;
    private String entityID;
    private String name;
    private String node;

    public Item(String paramString)
    {
      this.entityID = paramString;
    }

    public String getAction()
    {
      return this.action;
    }

    public String getEntityID()
    {
      return this.entityID;
    }

    public String getName()
    {
      return this.name;
    }

    public String getNode()
    {
      return this.node;
    }

    public void setAction(String paramString)
    {
      this.action = paramString;
    }

    public void setName(String paramString)
    {
      this.name = paramString;
    }

    public void setNode(String paramString)
    {
      this.node = paramString;
    }

    public String toXML()
    {
      StringBuilder localStringBuilder = new StringBuilder();
      localStringBuilder.append("<item jid=\"").append(this.entityID).append("\"");
      if (this.name != null)
        localStringBuilder.append(" name=\"").append(this.name).append("\"");
      if (this.node != null)
        localStringBuilder.append(" node=\"").append(this.node).append("\"");
      if (this.action != null)
        localStringBuilder.append(" action=\"").append(this.action).append("\"");
      localStringBuilder.append("/>");
      return localStringBuilder.toString();
    }
  }
}